
#include "./xbase/general.h"
#include <stdio.h>

int main(int argc, char *argv[])
{
  /*
  int i_err = 0;

  xbase_init();
  
  x_mem_pool_t * p_mp = NULL;
  p_mp = create_mem_pool(&i_err);
  if (p_mp == NULL) {
	return -1;
  }
  int * p_new = NULL;
  p_new = (int*)mem_alloc(p_mp, sizeof(int), &i_err);
  if (p_new != NULL){
	*p_new = 8813;
	printf("The value of the new int is : %d\r\n", *p_new);
  } else {
	printf("Failed to allocate new memory!\r\n");
  }

  int i = 1;
  int * p_arr = NULL;
  */

  ////////////////////////////////////////
  /*
  x_mem_block_t *p_blk = NULL;
  x_mem_block_t *p_list = NULL;
  int k = 0;

  p_blk = &(p_mp->mem_free_list);
  for (i = 0; i < UNIT_NUMBER; i++){
    p_list = (x_mem_block_t*)(p_blk->unit_array[i]);
    while(p_list != NULL){
      for(k = 0; k < UNIT_NUMBER; k++){
	printf("空闲内存链表第 %d 项,地址：%x，单元数：%d\r\n",k,p_list->unit_array[k],i+1);
      }
      p_list=p_list->p_next;
    }
  }
  */
  //////////////////////////////  

  /*
  p_arr = (int*)mem_alloc(p_mp, sizeof(int[5]), &i_err);
  if (p_arr != NULL){
	for(i=0;i<5;i++){
	  p_arr[i] = i+3;
	}
	for(i=0;i<5;i++){
	  printf("The value of the element of the int array is : %d\r\n", p_arr[i]);
	}
  } else {
	printf("Failed to allocate new memory!\r\n");
  }
  

  printf("The addr of p_int is :%d, the addr of p_arr is :%d\r\n",p_new, p_arr);
  
  mem_free(p_mp, p_new);
  x_mem_block_t *p_blk = NULL;
  x_mem_block_t *p_list = NULL;
  int k = 0;

  p_blk = &(p_mp->mem_free_list);
  for (i = 0; i < UNIT_NUMBER; i++){
    p_list = (x_mem_block_t*)(p_blk->unit_array[i]);
    while(p_list != NULL){
      for(k = 1; k <= (int)(p_list->unit_array[0])/*UNIT_NUMBER*/; k++){
	printf("空闲内存链表第 %d 项,地址：%d，单元数：%d\r\n",k,p_list->unit_array[k],i+1);
      }
      p_list=p_list->p_next;
    }
  }


  p_blk = &(p_mp->mem_used_list);
  for (i = 0; i < UNIT_NUMBER; i++){
    p_list = (x_mem_block_t*)(p_blk->unit_array[i]);
    while(p_list != NULL){
      for(k = 1; k <= (int)(p_list->unit_array[0])/*UNIT_NUMBER*/; k++){
	printf("在用内存链表第 %d 项,地址：%d，单元数：%d\r\n",k,p_list->unit_array[k],i+1);
      }
      p_list=p_list->p_next;
    }
  }

  mem_free(p_mp, p_arr);

  mem_pool_reset(p_mp);
  //system("PAUSE");
  printf("按回车键退出！\r\n");
  xbase_uninit();
*/
  getchar();
  return 0;
}
